package com.example.module_main;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class AdBannerBean implements Serializable {

    /**
     * code : 200
     * msg : 提示:ok
     * data : {"ad":[{"id":2,"title":"轮播2","pic":"http://su.bcebos.com/v1/lezhu-test/ad/201808/5b610d11375f0.png","content":"","url":"","begintime":1538150400,"endtime":1546012800,"status":1,"type":"link","value":102,"resource":200}]}
     */
    private List<AdBean> ad;

    public List<AdBean> getAd() {
        if (ad == null) {
            ad = new ArrayList<>();
        }
        return ad;
    }

    public void setAd(List<AdBean> ad) {
        this.ad = ad;
    }

    public static class AdBean {
        public AdBean(int id, String title, String pic, String url, int positionid) {
            this.id = id;
            this.title = title;
            this.pic = pic;
            this.url = url;
            this.positionid = positionid;
        }

        public AdBean() {

        }

        /**
         * id : 17
         * title : 商城顶部广告
         * pic : http://su.bcebos.com/v1/lezhu-test/ad/201808/mall_top.png
         * url :
         * positionid : 0
         */

        private int id;
        private String title;
        private String pic;
        private String url;
        private int positionid;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getPic() {
            return pic;
        }

        public void setPic(String pic) {
            this.pic = pic;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public int getPositionid() {
            return positionid;
        }

        public void setPositionid(int positionid) {
            this.positionid = positionid;
        }
    }


    //
    public ArrayList<AdBean> findBeanByPositionId(int positionid) {
        ArrayList<AdBean> templist = new ArrayList();
        for (int i = 0; i < getAd().size(); i++) {  //获取
            if (positionid == getAd().get(i).getPositionid() && templist.size() < 5) {
                templist.add(getAd().get(i));
            }
        }
        return templist;
    }
}
